<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
  <script src="../vue.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0;
      list-style: none;
    }

    .tit {
      width: 200px;
      line-height: 40px;
      display: flex;
      justify-content: space-around;
    }

    .tit h2 {
      /* display: inline-block; */
      cursor: pointer;
      /* width: 50px; */
    }

    .tit .active {
      color: orangered;
    }

    .cont {
      width: 200px;
      height: 300px;
      background: peru;
      display: flex;
      overflow: hidden;
    }

    .cont li {
      width: 200px;
      display: none;
    }

    .cont li.active {
      display: block;
    }
  </style>
</head>

<body>

  <div id="app">
    <div class="tit">
      <h2 :class="tabIndex==index?'active':''" v-for='(item,index) in tab' :key='item.title' @click='loginTab(index)'>
        {{ item.title }}
      </h2>
    </div>
    <ul class="cont">
      <li :class="tabIndex==index?'active':''" v-for='(item,index) in tab' :key="item.content">
        {{ item.content }}
      </li>
    </ul>

  </div>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        tabIndex: 0,
        tab: [
          {
            'title': '登录',
            'content': '内容1'
          },
          {
            'title': '注册',
            'content': '内容2'
          }
        ]
      },
      methods: {
        loginTab(i) {
          this.tabIndex = i
        }

      }
    })
  </script>
</body>

</html>